<?php
	$company_name = '<p>Company Name:<br /><input type="text" id="entry_372164349" name="entry.372164349" /></p>';
	$main_contact = '<p>Main Contact:<br /><input type="text" id="entry_303673867" name="entry.303673867" /></p>';
	$name = '<p>Name:<br /><input type="text" id="entry_1601199003" name="entry.1601199003" /></p>';
	$address = '<p>Address:<br /><input type="text" id="entry_319737558" name="entry.319737558" /></p>';
	$zip_code = '<p>Zip Code:<br /><input type="text" id="entry_641877084: name="entry_641877084" /></p>';
	$email = '<p>Email:<br /><input type="text" id="entry_301165779" name="entry.301165779" /></p>';
	$phone = '<p>Phone:<br /><input type="text" id="entry_1219136068" name="entry.1219136068" /></p>';
	$system_type = '<p>Type of System:<br /><select id="entry_1723387488" name="entry.1723387488"><option>Please Choose</option><option>Regular Hot Water</option><option>Space Heating</option><option>Space Heating + Hot Water</option><option>Pool</option></select></p>';
	$training_interest = '<p>Interested in Solar Hot Water Training?<br /><select id="entry_1768310470" name="entry.1768310470"><option>Yes</option><option>No</option></select></p>';
	$training_qty = '<p>How Many People Are Intersted In Training?<br /><input type="text" id="entry_857109503" name="entry.857109503" /></p>';
	$consulting_type = '<p>Type of Consulting:<br /><select id="entry_632260494" name="entry.632260494"><option>Project Management</option><option>Installation Training</option><option>Manufacturing Training &amp; Setup</option><option>Solar Thermal Market Development</option></select></p>';
	$budget = '<p>Budget:<br /><input type="text" id="entry_1888069277" name="entry.1888069277" /></p>';
	$timeline = '<p>Timeline:<br /><select id="entry_920592708" name="entry.920592708"><option>Please Choose</option><option>1-2 Weeks</option><option>3-4 Weeks</option><option>2-6 Months</option><option>7-12 Months</option></select></p>';
	$best_time = '<p>Best Time To Call:<br /><input type="text" id="entry_1627694919" name="entry.1627694919" /></p>';
	$source = '<p>How Did You Hear About Us?<br /><select id="entry_1518039105" name="entry.1518039105"><option>Internet</option><option>Press Release</option><option>Word of Mouth</option><option>Magazine</option></select></p>';
	$notes = '<p>Other Notes:<br /><textarea id="entry_1895058785" name="entry.1895058785"></textarea></p>';

	$customerlink = $_GET['customertype'];

	if (is_page(214) || $customerlink == residential) {
		$formtype = 'residential';
		$customertype = 'residential';
	} elseif (is_page(216) || $customerlink == commercial) {
		$formtype = 'commercial';
		$customertype = 'commercial';
	} elseif (is_page(221) || $customerlink == dealer) {
		$formtype = 'dealer';
		$customertype = 'dealer';
	} elseif (is_page(1165) || in_category(75)) {
		$formtype = 'training';
		$customertype = 'training';
	//} elseif {
	//	$formtype = 'consulting';
	//	$customertype = 'consulting';
	} else {
		$customertype = 'general';
	}

	$customer_type = '<input type="hidden" id="entry_20174185" name="entry.20174185" value="Customer Type: '.$customertype.'" />'
?>

<script type="text/javascript">var submitted=false;</script>
<iframe id="redirect" style="display:none;" onload="if(submitted) {window.location='<?php get_site_url(); ?>';}"></iframe>
<form id="contact-form" method="POST" action="https://docs.google.com/forms/d/1U28ncMaKn0H2D7tTNJAF-Da76wS-WxJ2V3J5Sq_svII/formResponse" target="redirect" onsubmit="alert('Thank You For Your Inquiry.');">
<!-- BEGIN DYNAMIC CONTENT -->

<?php // Residential Form
	if($formtype == 'residential') {
	echo $name;
	echo $zip_code;
	echo $email;
	echo $phone;
	echo $system_type;
	echo $budget;
	echo $timeline;
	echo $best_time;
	echo $source;
	echo $notes;
} elseif ($formtype == 'commercial') {
// Commercial Form 
	echo $company_name;
	echo $main_contact;
	echo $address;
	echo $zip_code;
	echo $email;
	echo $phone;
	echo $training_interest;
	echo $timeline;
	echo $best_time;
	echo $source;
	echo $notes;
} elseif ($formtype == 'dealer') {
// Dealer Form
	echo $company_name;
	echo $main_contact;
	echo $address;
	echo $zip_code;
	echo $email;
	echo $phone;
	echo $training_interest;
	echo $timeline;
	echo $best_time;
	echo $source;
	echo $notes;
} elseif ($formtype == 'training') {
// Training Form
	echo $company_name;
	echo $main_contact;
	echo $zip_code;
	echo $email;
	echo $phone;
	echo $training_qty;
	echo $timeline;
	echo $best_time;
	echo $source;
	echo $notes;
} elseif ($formtype == 'consulting') {
// Consulting Form
	echo $company_name;
	echo $main_contact;
	echo $address;
	echo $zip_code;
	echo $email;
	echo $phone;
	echo $training_interest;
	echo $consulting_type;
	echo $timeline;
	echo $best_time;
	echo $source;
	echo $notes;
} else {
// General Form
	echo $name;
	echo $zip_code;
	echo $email;
	echo $phone;
	echo $system_type;
	echo $budget;
	echo $timeline;
	echo $best_time;
	echo $source;
	echo $notes;
} ?>

<!-- END DYNAMIC CONTENT -->

<p><strong>Please Help Us Fight SPAM:</strong><br/>How Many Days Are There In A Week?</p>
<p><select name="test" id="testfield" >
	<option>1</option>
	<option>2</option>
	<option>3</option>
	<option>4</option>
	<option>5</option>
	<option>6</option>
	<option>7</option>
</select></p>

<input type="hidden" name="entry_744178762" id="entry.744178762" value="<?php the_permalink(); ?>" />
<?php echo $customer_type ; ?>

<div id="submitblock">
	<p><input type="submit" value="Submit Form" /></p>
</div>

<script>
   $(document).ready(
    function(){
        $('input:submit').attr('disabled',true);
        $('select#testfield').change(
            function(){
                if ($(this).val() == 7){
                    $('input:submit').removeAttr('disabled'); 
                }
                else {
                    $('input:submit').attr('disabled',true);
                }
            });
    });
</script>

</form>
